<!DOCTYPE html>
<meta charset="utf-8">
<script src="/common/get-host-info.sub.js"></script>
<body>
<script>
'use strict';
const params = new URLSearchParams(location.search);
const childURL = JSON.stringify(encodeURIComponent(params.get('childURL')));
const childName = JSON.stringify(params.get('childName'));
location.assign(`javascript:\`<body><script>
const child = window.open(${childURL}, ${childName});
const bc = new BroadcastChannel(${childName});

bc.addEventListener('message', ({data}) => {
  if (data === 'close') {
    close();
    return;
  }
  if (data === 'inspectChild') {
    const iframe = document.createElement('iframe');
    iframe.onload = () => {
      const payload = {
        childClosed: child.closed
      };
      iframe.contentWindow.postMessage(payload, '*');
    };
    iframe.src = '${get_host_info().HTTPS_ORIGIN}/html/cross-origin-opener-policy/resources/postback.html?channel=${params.get('childName')}';
    document.body.appendChild(iframe);
  }
});
<\/script></body>\``);
</script>
</body>
